package com.bjdd.jdy.ui.home;

import com.baidu.location.BDLocation;
import com.bjdd.jdy.Constant;
import com.bjdd.jdy.baidu.LocationUtils;
import com.bjdd.jdy.base.RxManager;
import com.bjdd.jdy.entity.User;
import com.bjdd.jdy.util.Event;
import com.bjdd.jdy.util.JumpUtil;
import com.bjdd.jdy.util.L;
import com.bjdd.jdy.util.SpUtil;
import com.bjdd.jdy.util.T;

import rx.Observable;

/**
 * Created by Administrator on 2017/4/18.
 */

public class HomePresenter extends HomeContract.Presenter {
    private Observable observable;
    @Override
    public void onStart() {
        if (SpUtil.getUser() == null || SpUtil.getUser().equals("") || SpUtil.getUser().getCarrierId() == null) {
            JumpUtil.toLogin(context);
            return;
        }
        rxManager.on(Constant.EVENT_LOCATION_ONCE,arg -> view.updateLocation((BDLocation)arg));
        LocationUtils.getInstance(context).startOnce();
    }

    public void unregister(){
        L.d("取消订阅");
        rxManager.unregister(Constant.EVENT_LOCATION_ONCE,observable);
    }

}
